from multiprocessing import Process
import os
import random


def run_proc(name):
    for i in range(random.randint(1, 5)):
        print("子进程运行中，name={},pid={}...,消耗{}".format(name, os.getpid(), i))

if __name__ == '__main__':
    print("父进程{}".format(os.getpid()))
    for i in range(5):
        p = Process(target=run_proc, args=('test{}'.format(i),))
        print('{}子进程要执行了'.format('test{}'.format(i)))
        p.start()
        p.join()
        print('子进程结束了')
